﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        SqlConnection cnn = new SqlConnection(@"Data Source=MURATK-PC;Initial Catalog=db_Ervahi;Integrated Security=True");
        public Form1()
        {
            InitializeComponent();
            veriGetir();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
        private void veriGetir()
        {

            cnn.Open();

            SqlCommand cmm = new SqlCommand("select * from tbl_Bilgiler");
            SqlDataAdapter adp = new SqlDataAdapter(cmm.CommandText, cnn.ConnectionString);
            DataSet ds = new DataSet();
            adp.Fill(ds);

            dataGridView1.DataSource = ds.Tables[0];
            cnn.Close();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (cnn.State == ConnectionState.Closed)
                {
                    cnn.Open();

                }

                SqlCommand cmm = new SqlCommand("select * from tbl_Bilgiler");
                SqlDataAdapter adp = new SqlDataAdapter(cmm.CommandText, cnn);
                DataSet ds = new DataSet();
                adp.Fill(ds);

                listView1.Items.Add(dataGridView1.SelectedCells[0].Value.ToString());
           

               

            }
            catch (Exception ex)
            {
                
                throw ex;
            }
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}
